package com.jdk.demo.fileChannel.openfile;

import java.io.File;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

public class Append {
	
	// APPEND：如果打开文件以进行写入访问，则字节将写入文件末尾而不是开始处
	public static void main(String[] args) throws Exception {
		File file = new File("o2.txt");
		Path path = file.toPath();
		FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.APPEND);
		// 在文件末尾追加了123
		fileChannel.write(ByteBuffer.wrap("123".getBytes()));
		fileChannel.close();
	}

}
